﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 装饰模式
{
    class DressUp
    {
        public DressUp() {
            Person xc = new Person("小菜");

            Console.WriteLine("第一种装扮：");
            Tshirts tx = new Tshirts();
            BigTrouser kk = new BigTrouser();

            tx.Decorate(xc);
            kk.Decorate(tx);
            kk.show();

            Console.ReadLine();
        }
    }

    //Person类-ConcreteComponent
    class Person {
        public Person() { }

        private string name;
        public Person(string name) {
            this.name = name;
        }
        public virtual void show() {
            Console.WriteLine("装扮的{0} ",this.name);
        }
    }

    //服饰类-Decorator
    class Finery : Person {
        protected Person component;

        //打扮
        public void Decorate(Person component) {
            this.component = component;
        }

        public override void show()
        {
            if (component != null) {
                component.show();
            }
        }
    }

    #region 具体的服饰类
    class Tshirts : Finery {
        public override void show()
        {
            Console.WriteLine("大T恤");
            base.show();
        }
    }
    class BigTrouser : Finery {
        public override void show()
        {
            Console.WriteLine("垮裤");
            base.show();
        }
    }
    #endregion
}
